﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07_Try语句
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 20;
            int c;

            try
            {
                c = a / 0;
            }
            catch (System.DivideByZeroException DivideByZero) //只捕获尝试除以零的错误，其他错误不捕获
            {
                Console.WriteLine(DivideByZero);
            }
            catch (Exception ex)//Exception 会捕获全部的错误
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("不管程序有没有报错，最总都会去执行的代码");
            }

            Console.ReadKey();
        }
    }
}
